package com.wolfstreet.wsonline.service.http;

import com.wolfstreet.wsonline.threadPool.TaskQueue;


public class ConnectionLogic {
	/**
	 * 单实例连接处理对象
	 */
	private static ConnectionLogic instance;

	/**
	 * 连接队列
	 */
	private TaskQueue requestQueue;

	/**
	 * 最大任务请求数
	 */
	private static final int maxCount = 10;

	/**
	 * 私有构造函数
	 */
	private ConnectionLogic() {
		requestQueue = new TaskQueue(maxCount);
	}

	/**
	 * 单实例对象
	 * 
	 * @return 单实例连接处理对象
	 */
	public synchronized static ConnectionLogic getInstance() {
		if (instance == null) {
			instance = new ConnectionLogic();
		}
		return instance;
	}

	/**
	 * 增加请求任务
	 * 
	 * @param req
	 *            请求任务
	 */
	public void addRequest(ConnectionTask req) {
		if (requestQueue != null) {
			requestQueue.addTask(req);
		}
	}

}
